package com.backend.service.impl;

import com.backend.mapper.UserMapper;
import com.backend.pojo.dto.LeaveRequestDTO;
import com.backend.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StuServiceImpl implements StuService {
    @Autowired
    UserMapper userMapper;

    @Override
    public void leave(LeaveRequestDTO leaveRequestDTO) {
        if (leaveRequestDTO.getDate1().after(leaveRequestDTO.getDate2())){
            throw new IllegalArgumentException("开始时间不能大于结束时间");
        }
        if (leaveRequestDTO.getDate1() == null || leaveRequestDTO.getDate2() == null) {
            throw new IllegalArgumentException("请假时间不能为空");
        }
        leaveRequestDTO.setStatus(0);//表示待审核
        userMapper.leave(leaveRequestDTO);
    }
}
